#ifndef DVHISTOGRAM_H
#define DVHISTOGRAM_H

#include <qwt_plot.h>
#include <qwt_series_data.h>
#include <QMap>
#include "dvDatabaseController.h"
#include "dvDatabaseControllerUsable.h"

class Histogram;

class dvHistogram : public QwtPlot, public dvDatabaseControllerUsable
{
    Q_OBJECT
public:
    dvHistogram(QWidget *parent = 0);
    ~dvHistogram();

    void clear();

    void showLegend(bool show);

    void insertBar(int region, double value, QColor &color, bool attached = true);

    void removeBar(int region);

    void rebuildHistogram();

    void showBar(int region, bool show);

    void setHiddenAllBars(bool hidden);

    void setCheckedItemsLegend();

    int  barCount();

private slots:
    void showItem(QwtPlotItem *, bool on);

private:
    bool m_showLegend;
    QwtLegend *m_pLegend;
    QString    m_date;
    QMap<int, Histogram*> m_bars;
    QMap<int, double>     m_barsValues;
    QMap<int, QColor>     m_barsColors;
    QMap<int, bool>       m_barsAttached;
};

#endif // DVHISTOGRAM_H
